<?php
class Pelapor_alamat_model extends MY_Model {
	
    function Pelapor_alamat_model(){
        parent::MY_Model();
        $this->load->database();
        $this->table_name = "pelapor_alamat";
        $this->table_fields = array('lapor_alm_id',	'lapor_alm_alamat',	'lapor_alm_kode_pos',
        	'lapor_alm_kode_area','lapor_alm_kota','lapor_alm_propinsi','lapor_id');
    }
    
    function select_last_entry($search_key=false, $where=false, $limit=10, $offset=0, $orderby=""){
//    	$sql = $sqlo = $sqlw = "";
//    	
//    	if ($search_key){
//    		$sqlw .= ($sqlw? " AND " : ""). 
//    				"(propinsi_id LIKE '%$search_key%' OR 
//    				 propinsi_nama LIKE '%$search_key%')";
//    	}
//    	if ($where){
//    		$sqlw .= ($sqlw? " AND " : "").$where;
//    	}
//    	$sqlw = $sqlw? " WHERE $sqlw " : "";
//    	
//    	if ($orderby){
//    		$sqlo = "ORDER BY $orderby";
//    	}
//    	return $query = $this->db->query(
//    		"SELECT * FROM ".$this->table_name.
//    		"$sqlw $sqlo LIMIT $offset,$limit");
    }
        
    function select_by_id($id){
    	return $this->db->get_where(array('lapor_alm_id' => $id));
    }
    
    function select_by_pelapor($laporID){
    	return $this->get_where(array('lapor_id' => $laporID));
    }
}